<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>16_事件-绑定事件基本使用</title>
  <style>
    .box {
      width: 100px;
      height: 100px;
      background-color: orange;
      margin-top: 10px;
    }
  </style>
</head>
<body>

  <div id="app">
    <h3>1. 基本的写法</h3>
    <div class="box" v-on:click="handleClick"></div>

    <h3>2. 语法糖写法(重点掌握)</h3>
    <div class="box" @click="handleClick"></div>

    <h3>3. 绑定的方法表达式(不常用, 不推荐)</h3>
    <h4>计数: {{ count }}</h4>
    <button @click="count++">绑定的方法表达式</button>

    <h3>4. 绑定其他方法</h3>
    <button @mousemove="handleClick2">绑定其他方法</button>

    <h3>5. 绑定多个方法</h3>
    <div class="box" @click="handleClick3" @mousemove="handleClick4">绑定多个方法</div>

  </div>
  <script src="../lib/vue.js"></script>
  <script>
    const { createApp, ref } = Vue

    const app = createApp({
      setup() {
        const count = ref(0)

        const handleClick = () => {
          count.value++
        }

        const handleClick2 = () => {
          console.log("按钮被点击了")
        }

        const handleClick3 = () => {
          console.log("div被点击了")
        }

        const handleClick4 = () => {
          console.log("div被移动了")
        }

        return {
          count,
          handleClick,
          handleClick2,
          handleClick3,
          handleClick4
        }
      }
    })

    app.mount("#app")

  </script>
  
</body>
</html>